package ua.org.nuos.sdms.clientgui.client.view;

import com.vaadin.ui.Button;
import ua.org.nuos.sdms.clientgui.client.components.factory.WindowFactory;
import ua.org.nuos.sdms.clientgui.client.components.window.AbstractWindow;
import ua.org.nuos.sdms.clientgui.server.AppProxy;

/**
 * Created by IntelliJ IDEA.
 * User: dio
 * Date: 26.02.12
 * Time: 16:45
 * To change this template use File | Settings | File Templates.
 */
public class RegisterNewUserWindow extends AbstractWindow {

    private static final String WIDTH = "350";
    private static final String HEIGHT = "337";
    private static final String CAPTION = "Создание новой учётной записи";

    public static final String ID = RegisterNewUserWindow.class.getSimpleName();

    public RegisterNewUserWindow() {
        init();
    }

    private void init() {
        AppProxy.getInstance().getComponentLocator().addWindow(ID, this);
        initComponents();
    }

    public void initComponents() {
        window = WindowFactory.getModalWindow(WIDTH, HEIGHT, CAPTION);
        RegisterNewUserComponent registerNewUserComponent = new RegisterNewUserComponent() {
            public Button.ClickListener getCancelClickListener() {
                return new Button.ClickListener() {

                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        (window.getParent()).removeWindow(window);
                    }
                };
            }
        };
        window.addComponent(registerNewUserComponent.getContent());
    }
}
